package cc.ccoke.design.singleton;

/**
 * 静态内部类实现
 * @author ccoke
 */
public class StaticInnerClassSingleton {

    /**
     * 添加私有构造函数，防止类被外部创建实例
     */
    private StaticInnerClassSingleton() {

    }

    private static class SingletonHolder {
        // 只有当类被调用时，才会进行初始化
        private final static StaticInnerClassSingleton instance = new StaticInnerClassSingleton();
    }

    /*
     * 获取实例的Getter方法
     */
    public synchronized static StaticInnerClassSingleton getInstance() {
        return SingletonHolder.instance;
    }

}
